package news.dao;


import news.model.Menu;
import news.model.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleDao {
    List<Role> roleList(Role role);

    @Select("select id,name from menu where type = 1")
    List<Menu> menus();

    void save(Role role);

    @Insert("insert into role_menu(menu_id,role_id)value(#{menuId},#{roleId})")
    void saveRoleMenu(@Param("menuId") Integer menuId,@Param("roleId") Integer id);

    @Delete("delete from role where id = #{id}")
    void deleteRole(Integer id);

    @Delete("delete from role_menu where role_id = #{id}")
    void deleteRoleMenu(Integer id);

    Role findRoleById(Integer id);

    void update(Role role);
}
